package View.SetupScreens;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;

import Model.Game;
import View.RaceIcon;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

/**
 * @author Emily Curtin Creates the Race setup screen. - Creates files for each
 *         race image - Creates file for selector bars - Creates raceIcons for
 *         each raceBlock - Creates JLabels for each player - Creates ComboBoxes
 *         with the race choices for each player - Sets race choices for each
 *         player and calls next card on button click - NOTE: It is okay for
 *         more than one player to be the same race.
 */
public class RaceChooser extends JPanel {

	public JButton setPlayerRaceButton;

	public final JComboBox p1comboBox;
	public final JComboBox p2comboBox;
	public final JComboBox p3comboBox;
	public final JComboBox p4comboBox;

	/**
	 * Initializes, constructs, and sets parameters for all swing components.
	 * Includes actionlistener to set race parameters for players and call the
	 * next card.
	 * 
	 * @param game
	 *            - an instance of the main Game. The parameter is "final" so
	 *            that the inner actionlistener class can access it.
	 */

	public RaceChooser(final Game game) {

		setBackground(Color.BLACK);
		setLayout(null);
		setPreferredSize(new Dimension(1200, 800));

		JLabel lblNewLabel = new JLabel("CHOOSE YOUR RACE");
		lblNewLabel.setForeground(new Color(204, 153, 0));
		lblNewLabel.setFont(new Font("Helvetica", Font.BOLD, 64));
		lblNewLabel.setBounds(317, 19, 700, 80);
		add(lblNewLabel);

		String filePath = "svn/trunk/GraphicResources/RaceIconsPurple/";
		String selectorPath = "RACE-SELECTBARS.png";

		RaceIcon bonzoid = new RaceIcon("RACE-BONZOID.png", selectorPath);
		bonzoid.setBounds(937, 175, 80, 80);
		add(bonzoid);

		RaceIcon buzzite = new RaceIcon("RACE-LEGGITE.png", selectorPath);
		buzzite.setBounds(387, 175, 80, 80);
		add(buzzite);

		RaceIcon flapper = new RaceIcon("RACE-FLAPPER.png", selectorPath);
		flapper.setBounds(560, 175, 80, 80);
		add(flapper);

		RaceIcon humanoid = new RaceIcon("RACE-HUMANOID.png", selectorPath);
		humanoid.setBounds(749, 175, 80, 80);
		add(humanoid);

		RaceIcon ugalite = new RaceIcon("RACE-GOLLUMER.png", selectorPath);
		ugalite.setBackground(Color.BLUE);
		ugalite.setBounds(213, 175, 80, 80);
		add(ugalite);

		JLabel bonzoidLabel = new JLabel("BONZOID");
		bonzoidLabel.setForeground(new Color(204, 153, 0));
		bonzoidLabel.setFont(new Font("Helvetica", Font.BOLD, 32));
		bonzoidLabel.setBounds(197, 312, 200, 50);
		add(bonzoidLabel);

		JLabel flapperLabel = new JLabel("FLAPPER");
		flapperLabel.setForeground(new Color(204, 153, 0));
		flapperLabel.setFont(new Font("Helvetica", Font.BOLD, 32));
		flapperLabel.setBounds(534, 312, 200, 50);
		add(flapperLabel);

		JLabel buzziteLabel = new JLabel("BUZZITE");
		buzziteLabel.setForeground(new Color(204, 153, 0));
		buzziteLabel.setFont(new Font("Helvetica", Font.BOLD, 32));
		buzziteLabel.setBounds(371, 312, 200, 50);
		add(buzziteLabel);

		JLabel humanoidLabel = new JLabel("HUMANOID");
		humanoidLabel.setForeground(new Color(204, 153, 0));
		humanoidLabel.setFont(new Font("Helvetica", Font.BOLD, 32));
		humanoidLabel.setBounds(716, 312, 200, 50);
		add(humanoidLabel);

		JLabel ugaliteLabel = new JLabel("UGALITE");
		ugaliteLabel.setForeground(new Color(204, 153, 0));
		ugaliteLabel.setFont(new Font("Helvetica", Font.BOLD, 32));
		ugaliteLabel.setBounds(916, 312, 200, 50);
		add(ugaliteLabel);

		/* initialize 'PLAYER X' labels */
		JLabel p1Label = new JLabel("PLAYER 1");
		p1Label.setFont(new Font("Helvetica", Font.PLAIN, 30));
		p1Label.setForeground(new Color(204, 153, 0));
		p1Label.setBounds(414, 390, 227, 30);
		add(p1Label);

		JLabel p2Label = new JLabel("PLAYER 2");
		p2Label.setForeground(new Color(204, 153, 0));
		p2Label.setFont(new Font("Helvetica", Font.PLAIN, 30));
		p2Label.setBounds(414, 440, 227, 30);
		add(p2Label);

		JLabel p3Label = new JLabel("PLAYER 3");
		p3Label.setForeground(new Color(204, 153, 0));
		p3Label.setFont(new Font("Helvetica", Font.PLAIN, 30));
		p3Label.setBounds(414, 494, 227, 30);
		add(p3Label);

		JLabel p4Label = new JLabel("PLAYER 4");
		p4Label.setForeground(new Color(204, 153, 0));
		p4Label.setFont(new Font("Helvetica", Font.PLAIN, 30));
		p4Label.setBounds(414, 545, 227, 30);
		add(p4Label);

		/* initialize AND ADD ComboBoxes */
		String[] raceChoices = { "BONZOID", "BUZZITE", "FLAPPER", "HUMANOID", "UGALITE" };

		p1comboBox = new JComboBox(raceChoices);
		p1comboBox.setBounds(655, 386, 138, 30);
		add(p1comboBox);

		p2comboBox = new JComboBox(raceChoices);
		p2comboBox.setBounds(656, 437, 138, 30);
		p2comboBox.setSelectedIndex(1);
		add(p2comboBox);

		p3comboBox = new JComboBox(raceChoices);
		p3comboBox.setBounds(657, 491, 138, 30);
		p3comboBox.setSelectedIndex(2);
		add(p3comboBox);

		p4comboBox = new JComboBox(raceChoices);
		p4comboBox.setBounds(653, 539, 138, 30);
		p4comboBox.setSelectedIndex(3);
		add(p4comboBox);

		setPlayerRaceButton = new JButton("SET PLAYER RACES");
		setPlayerRaceButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		setPlayerRaceButton.setBackground(new Color(0, 0, 0));
		setPlayerRaceButton.setForeground(new Color(204, 153, 0));

		setPlayerRaceButton.setFont(new Font("Helvetica", Font.PLAIN, 41));
		setPlayerRaceButton.setBounds(20, 472, 447, 56);
		add(setPlayerRaceButton);

	}

}
